import Vue from 'vue'
import Router from 'vue-router'
// import NProgress from 'nprogress'   // 这个库没安装   是一个 切换路由 加载动画效果的 库
// import 'nprogress/nprogress.css'
Vue.use(Router)

const router = new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      redirect: { path: '/home' }
    },

    // ------------------------首页------------------------------------------------
    {
      path: '/home',
      name: 'home',
      //路由懒加载 1 vue异步组件技术 ==== 异步加载  resolve
      // component: resolve => require(['@/views/Login'], resolve),
      //路由懒加载 2 使用 import 官网方法
      component: () => import('@/views/home/Home'),
      meta: { footShow: true }, // 控制底部 tabar
    },

    // ------------------------阅读训练------------------------------------------------
    {
      path: '/home/readtype',   // 选择题目类型
      name: 'readtype',
      component: () => import('@/views/home/reading/Readtype'),
    },
    {
      path: '/home/deepread',   // 深度阅读
      name: 'deepread',
      component: () => import('@/views/home/reading/deepread/Deepread'),
    },
    {
      path: '/home/reportread',   // 深度阅读(练习报告)
      name: 'reportread',
      component: () => import('@/views/home/reading/deepread/Reportread'),
    },
    {
      path: '/home/choosefill',   // 选词填空
      name: 'choosefill',
      component: () => import('@/views/home/reading/choosefill/Choosefill'),
    },
    {
      path: '/home/reportfill',   // 选词填空(练习报告)
      name: 'reportfill',
      component: () => import('@/views/home/reading/choosefill/Reportfill'),
    },
    {
      path: '/home/readmatch',   // 阅读匹配
      name: 'readmatch',
      component: () => import('@/views/home/reading/readmatch/Readmatch'),
    },
    {
      path: '/home/reportmatch',   // 阅读匹配(练习报告)
      name: 'reportmatch',
      component: () => import('@/views/home/reading/readmatch/Reportmatch'),
    },
    {
      path: '/home/readanswer',   // 阅读简答
      name: 'readanswer',
      component: () => import('@/views/home/reading/readanswer/Readanswer'),
    },
    {
      path: '/home/reportanswer',   // 阅读简答(练习报告)
      name: 'reportanswer',
      component: () => import('@/views/home/reading/readanswer/Reportanswer'),
    },
    {
      path: '/home/readfill',   // 阅读填空
      name: 'readfill',
      component: () => import('@/views/home/reading/readfill/Readfill'),
    },
    {
      path: '/home/reportblanks',   // 阅读填空(练习报告)
      name: 'reportblanks',
      component: () => import('@/views/home/reading/readfill/Reportblanks'),
    },
    {
      path: '/home/sectionmatch',   // 段落匹配
      name: 'sectionmatch',
      component: () => import('@/views/home/reading/sectionmatch/Sectionmatch'),
    },
    {
      path: '/home/reportsection',   // 段落匹配(练习报告)
      name: 'reportsection',
      component: () => import('@/views/home/reading/sectionmatch/Reportsection'),
    },

    // ------------------------听力理解------------------------------------------------
    {
      path: '/home/listentype',   // 选择题目类型
      name: 'listentype',
      component: () => import('@/views/home/listening/Listentype'),
    },
    {
      path: '/home/hearing',   // 听力题
      name: 'hearing',
      component: () => import('@/views/home/listening/hearing/Hearing'),
    },
    {
      path: '/home/reporthear',   // 听力题(练习报告)
      name: 'reporthear',
      component: () => import('@/views/home/listening/hearing/Reporthear'),
    },
    {
      path: '/home/hearanswer',   // 听力简答
      name: 'hearanswer',
      component: () => import('@/views/home/listening/hearanswer/Hearanswer'),
    },
    {
      path: '/home/reportreply',   // 听力简答(练习报告)
      name: 'reportreply',
      component: () => import('@/views/home/listening/hearanswer/Reportreply'),
    },
    {
      path: '/home/hearfill',   // 听力填空
      name: 'hearfill',
      component: () => import('@/views/home/listening/hearfill/Hearfill'),
    },
    {
      path: '/home/reportlisten',   // 听力填空(练习报告)
      name: 'reportlisten',
      component: () => import('@/views/home/listening/hearfill/Reportlisten'),
    },

    // ------------------------语法训练------------------------------------------------
    {
      path: '/home/grammartype',   // 选择题目类型
      name: 'grammartype',
      component: () => import('@/views/home/grammar/Grammartype'),
    },
    {
      path: '/home/grammar',  // 语法训练
      name: 'grammar',
      component: () => import('@/views/home/grammar/Grammar')
    },
    {
      path: '/home/reportyufa',   // 语法训练(练习报告)
      name: 'reportyufa',
      component: () => import('@/views/home/grammar/Reportyufa'),
    },



    // -----------------------信息页-----------------------------------------------------
    {
      path: '/message',   // 信息页
      name: 'message',
      component: () => import('@/views/message/Message'),
      meta: { footShow: true }, // 控制底部 tabar
    },
    {
      path: '/message/:id',   // 信息页详情
      name: 'msgdetail',
      component: () => import('@/views/message/Msgdetail')
    },


    // -----------------------个人中心---------------------------------------------------
    {
      path: '/user',   // 个人中心首页
      name: 'user',
      component: () => import('@/views/user/User'),
      meta: { footShow: true }, // 控制底部 tabar
    },
    {
      path: '/user/login',  // 登录页
      name: 'login',
      component: () => import('@/views/user/Login'),
    },
    {
      path: '/user/regist',   // 注册页
      name: 'regist',
      component: () => import('@/views/user/Regist'),
    },
    {
      path: '/user/password',   // 修改密码
      name: 'password',
      component: () => import('@/views/user/Password'),
    },
    {
      path: '/user/feedback',   // 意见反馈
      name: 'feedback',
      component: () => import('@/views/user/Feedback'),
    },
    {
      path: '/user/notes',   // 复习笔记
      name: 'notes',
      component: () => import('@/views/user/Notes'),
    },
    {
      path: '/user/personalrepair',   // 个人信息修改
      name: 'personalrepair',
      component: () => import('@/views/user/Personalrepair'),
    },

    {
      path: '/develop',   // 开发中
      name: 'develop',
      component: () => import('@/views/Developing'),
    },

    {
      path: '*',   // 404
      name: 'notfound',
      component: () => import('@/views/Notfound'),
    },

  ]
});

//路由守卫
// router.beforeEach((to, from, next) => {
//   if (to.path !== from.path) {
//     NProgress.start();  // 这是一个npm 下载的包 等等上面要import引入
//   }
//   next();
// });

// router.afterEach( route => {
//   NProgress.done();
// })

export default router
